﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;

namespace UtilsLib.UtilsFile
{
    public class FileRow
    {
        //Fields
        private List<FileColumn> _columns;
        private int _nbColumns;
        private int _rowNumber;

        //Properties
        public List<FileColumn> Columns
        {
            get { return _columns; }
            set { _columns = value; }
        }

        /// <summary>
        /// Empty Constructor
        /// </summary>
        public FileRow()
        {
            _columns = new List<FileColumn>();
            _nbColumns = _columns.Count;
            _rowNumber = -1;
        }

        /// <summary>
        /// Create a row with the columns value
        /// </summary>
        /// <param name="columns">The values in the columns</param>
        public FileRow(List<string> columns)
        {
            //_columns = columns.Cast<FileColumn>().ToList();
            _columns = new List<FileColumn>();
            foreach (string col in columns)
                _columns.Add(new FileColumn(col));
            _nbColumns = _columns.Count;
            _rowNumber = -1;
        }

        public FileRow(List<FileColumn> columns)
        {
            _columns = columns;
            _nbColumns = _columns.Count;
            _rowNumber = -1;
        }

        /// <summary>
        /// Create a row with the columns value and the row number
        /// </summary>
        /// <param name="columns">The values in the columns</param>
        /// <param name="rowNumber">The row number</param>
        public FileRow(List<string> columns, int rowNumber)
        {
            //_columns = columns.Cast<FileColumn>().ToList();
            _columns = new List<FileColumn>();
            foreach (string col in columns)
                _columns.Add(new FileColumn(col));
            _nbColumns = _columns.Count;
            _rowNumber = rowNumber;
        }
        public FileRow(List<FileColumn> columns, int rowNumber)
        {
            _columns = columns;
            _nbColumns = _columns.Count;
            _rowNumber = rowNumber;
        }

        public List<string> GetRow()
        {
            List<string> result = new List<string>();

            foreach (FileColumn col in this._columns)
                result.Add(col.ColumnValue);

            return result;
        }

    }
}
